<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css"
          href="css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <script type="text/javascript" src="js/ckform.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script src="js/jquery.min.js?v=2.1.4"></script>

    <style type="text/css">
        body {
            font-size: 20px;
            padding-bottom: 40px;
            background-color: #e9e7ef;
        }

        .sidebar-nav {
            padding: 9px 0;
        }

        @media ( max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
</head>
<body>
<form class="form-inline definewidth m20" action="#" method="get">
    <font color="#777777"><strong>小类信息：</strong></font>

</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th>小类名称</th>
        <th>介绍</th>
        <th>删除</th>
    </tr>
    </thead>
    <tbody id="tbody">
    <%--存放数据行： --%>
    <tr>
        <%--			   <td>娱乐</td>--%>
        <%--			   <td>阿斯顿啥放</td>--%>
        <td>
            <%--				   <button type="submit">删除</button>--%>
        </td>
    </tr>
    </tbody>

</table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" id="addnew">
    <a href="subtype_add.jsp?typeid=${param.typeid}">添加小类</a>
</button>

<script type="text/javascript">
    $(function () {
        findSubTypeByTypeid();
    })

    //查询当前大类别下的，所有小类别
    function findSubTypeByTypeid() {
        $.get("/btype/findSubTypeByTid?typeid=${param.typeid}", function (rs) {
            $(rs).each(function (index, item) {
                var trs = `<tr>
							<td style="display: none">` + item.typeid + `</td>
							<td>` + item.typename + `</td>
							<td>` + item.typedes + `</td>
							<td>
								<button type="button" class="deleteSubTypeBtn">删除</button>
							</td>
						</tr>`;
                $("#tbody").append(trs);
            });
        });
    }

    //删除小类
    $(document).on('click', '.deleteSubTypeBtn', function () {
        var flag = window.confirm("您确定要删除吗?");
        if (flag) {//确定
            var typeid = $(this).parents("tr").children().eq(0).text();
            $.get("/btype/deleteSubTypeBtn?typeid=" + typeid, function (result) {
                if (result.msg) {//删除成功
                    alert(result.msg);
                    window.location.reload();
                } else {
                    alert(result.error);
                }
            });
        }
    });
</script>

</body>

</html>
